package com.marvels.loanapply.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.marvels.common.constants.MarvelsConstant;
import com.marvels.common.dto.BasicDataDTO;
import com.marvels.common.dto.MarvelsResultDTO;
import com.marvels.common.exception.MarvelsBusinessException;
import com.marvels.common.exception.MarvelsErrorCode;
import com.marvels.common.utils.MarvelsLogUtil;
import com.marvels.loanapply.api.LoanBasicDataApi;

/**
 * 对外提供基础数据查询服务
 * @author wangliang
 *
 */

@RestController
@RequestMapping("/loanapply/basic_data/api")
public class LoanApplyBasicDataApiController {
	@Autowired
	private LoanBasicDataApi loanBasicDataApi;
	
	/**
	 * 获取进件基表数据-贷款信息tab
	 * @return
	 */
	@RequestMapping("/getBasicDatas")
	@ResponseBody
	public MarvelsResultDTO getBasicDatas(){
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),null);
//		try {
//			Map<String,List<BasicDataDTO>> map = new HashMap<String,List<BasicDataDTO>>();
//			map.put(MarvelsConstant.PURPOSE_LIST, loanBasicDataApi.getPurposeList());
//			map.put(MarvelsConstant.PAYMENT_MODE_LIST, loanBasicDataApi.getPaymentModeList());
//			map.put(MarvelsConstant.LIFE_INSURANCE_TYPE_LIST, loanBasicDataApi.getLifeInsuranceTypeList());
//			map.put(MarvelsConstant.INSURANCE_TYPE_LIST, loanBasicDataApi.getInsuranceTypeList());
//			map.put(MarvelsConstant.INSURANCE_STATUS_LIST, loanBasicDataApi.getInsuranceStatusList());
//			map.put(MarvelsConstant.INSURANCE_COMPANY_LIST, loanBasicDataApi.getInsuranceCompanyList());
//			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), map);
//		}catch (MarvelsBusinessException e) {
//			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
//		}catch(Exception e){
//			MarvelsLogUtil.getInstance().error("[getBasicDatas] error: ",e);
//			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(), e);
//		}
	}
	
	/**
	 * 获取进件基表数据-客户信息tab
	 * @return
	 */
	@RequestMapping("/getCustomerBasicDatas")
	@ResponseBody
	public MarvelsResultDTO getCustomerBasicDatas(){
//		try {
//			Map<String,List<BasicDataDTO>> map = new HashMap<String,List<BasicDataDTO>>();
//			map.put(MarvelsConstant.EMPLOY_TYPE_LIST, loanBasicDataApi.getEmployTypeList());
//			map.put(MarvelsConstant.MARITAL_STATUS_LIST, loanBasicDataApi.getMaritalStatusList());
//			map.put(MarvelsConstant.EDUCATION_LEVEL_LIST, loanBasicDataApi.getEducationLevelList());
//			map.put(MarvelsConstant.LIVE_TYPE_LIST, loanBasicDataApi.getLiveTypeList());
//			map.put(MarvelsConstant.PROVINCE_LIST, loanBasicDataApi.getProvinceList());
//			map.put(MarvelsConstant.CITY_LIST, loanBasicDataApi.getCityList());
//			map.put(MarvelsConstant.REGION_LIST, loanBasicDataApi.getRegionList());
//			map.put(MarvelsConstant.COMPANY_TYPE_LIST, loanBasicDataApi.getCompanyTypeList());
//			map.put(MarvelsConstant.WORKTIME_TYPE_LIST, loanBasicDataApi.getWorkTimeTypeList());
//			map.put(MarvelsConstant.INCOME_TYPE_LIST, loanBasicDataApi.getIncomeTypeList());
//			map.put(MarvelsConstant.RELATION_LIST, loanBasicDataApi.getRelationList());
//			map.put(MarvelsConstant.RELATION_OTHER_LIST, loanBasicDataApi.getRelationOtherList());
//			map.put(MarvelsConstant.PHONE_CHK_RESULT_LIST, loanBasicDataApi.getPhoneCheckResultList());
//			map.put(MarvelsConstant.ENTERPRISE_SCALE_TYPE_LIST, loanBasicDataApi.getEnterpriseScaleTypeList());
//			map.put(MarvelsConstant.THREE_CAREER_TYPE_LIST, loanBasicDataApi.getThreeCareerTypeList());
//			map.put(MarvelsConstant.TWO_CAREER_TYPE_LIST, loanBasicDataApi.getTwoCareerTypeList());
//			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), map);
//		}catch (MarvelsBusinessException e) {
//			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
//		}catch(Exception e){
//			MarvelsLogUtil.getInstance().error("[getBasicDatas] error: ",e);
//			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(), e);
//		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),null);
	}
	
	/**
	 * 获取产品用途列表
	 * @return
	 */
	@RequestMapping("/getPurposeList")
	@ResponseBody
	public MarvelsResultDTO getPurposeList(){
		List<BasicDataDTO> list = null;
		try {
			list = loanBasicDataApi.getPurposeList();
		}catch (MarvelsBusinessException e) {
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		}catch(Exception e){
			MarvelsLogUtil.getInstance().error("[getPurposeList] error: ",e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(), e);
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), list);
	}
	
	/**
	 * 获取缴费方式列表
	 * @return
	 */
	@RequestMapping("/getPaymentModeList")
	@ResponseBody
	public MarvelsResultDTO getPaymentModeList(){
		List<BasicDataDTO> list = null;
		try {
			list = loanBasicDataApi.getPaymentModeList();
		}catch (MarvelsBusinessException e) {
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		}catch(Exception e){
			MarvelsLogUtil.getInstance().error("[getPaymentModeList] error: ",e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(), e);
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), list);
	}
	
	/**
	 * 获取寿险类型列表
	 * @return
	 */
	@RequestMapping("/getLifeInsuranceTypeList")
	@ResponseBody
	public MarvelsResultDTO getLifeInsuranceTypeList(){
		List<BasicDataDTO> list = null;
		try {
			list = loanBasicDataApi.getLifeInsuranceTypeList();
		}catch (MarvelsBusinessException e) {
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		}catch(Exception e){
			MarvelsLogUtil.getInstance().error("[getLifeInsuranceTypeList] error: ",e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(), e);
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), list);
	}
	
	/**
	 * 获取保单类型列表
	 * @return
	 */
	@RequestMapping("/getInsuranceTypeList")
	@ResponseBody
	public MarvelsResultDTO getInsuranceTypeList(){
		List<BasicDataDTO> list = null;
		try {
			list = loanBasicDataApi.getInsuranceTypeList();
		}catch (MarvelsBusinessException e) {
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		}catch(Exception e){
			MarvelsLogUtil.getInstance().error("[getInsuranceTypeList] error: ",e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(), e);
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), list);
	}
	
	/**
	 * 获取保单状态列表
	 * @return
	 */
	@RequestMapping("/getInsuranceStatusList")
	@ResponseBody
	public MarvelsResultDTO getInsuranceStatusList(){
		List<BasicDataDTO> list = null;
		try {
			list = loanBasicDataApi.getInsuranceStatusList();
		}catch (MarvelsBusinessException e) {
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		}catch(Exception e){
			MarvelsLogUtil.getInstance().error("[getInsuranceStatusList] error: ",e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(), e);
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), list);
	}
	
	/**
	 * 获取保险公司列表
	 * @return
	 */
	@RequestMapping("/getInsuranceCompanyList")
	@ResponseBody
	public MarvelsResultDTO getInsuranceCompanyList(){
		List<BasicDataDTO> list = null;
		try {
			list = loanBasicDataApi.getInsuranceCompanyList();
		}catch (MarvelsBusinessException e) {
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		}catch(Exception e){
			MarvelsLogUtil.getInstance().error("[getInsuranceCompanyList] error: ",e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(), e);
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), list);
	}
	
	
	/**
	 * 获取亲属关系
	 * @return
	 */
	@RequestMapping("/getRelationList")
	@ResponseBody
	public MarvelsResultDTO getRelationList(){
		List<BasicDataDTO> list = null;
		try {
			list = loanBasicDataApi.getRelationList();
		}catch (MarvelsBusinessException e) {
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		}catch(Exception e){
			MarvelsLogUtil.getInstance().error("[getInsuranceCompanyList] error: ",e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(), e);
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), list);
	}
}
